MYUTILS:=myutils

MYUTILS_BASEDIR:=$(BASEDIR)/$(MYUTILS)

MYUTILS_CC:=g++
MYUTILS_LD:=g++

MYUTILS_MODULES_DEPENDENCIES:=mycrypto mymem myrandom

MYUTILS_INCFLAGS:=-I$(MYUTILS_BASEDIR)/inc -I$(BASEDIR)/common/inc $(patsubst %, -I$(BASEDIR)/%/inc, $(MYUTILS_MODULES_DEPENDENCIES))

ifeq ($(SYSTEM), MINGW32_NT-5.1)
MYUTILS_DEBUG_CFLAGS:=-g -Wall -W -Woverloaded-virtual -D_REENTRANT -DDEBUG $(MYUTILS_INCFLAGS)
MYUTILS_DEBUG_LDFLAG:=
MYUTILS_DEBUG_LIBS:=

MYUTILS_RELEASE_CFLAGS:=-Wall -W -Woverloaded-virtual -D_REENTRANT -DRELEASE $(MYUTILS_INCFLAGS)
MYUTILS_RELEASE_LDFLAG:=
MYUTILS_RELEASE_LIBS:=

MYUTILS_SCRAMBLED_CFLAGS:=-Wall -W -Woverloaded-virtual -D_REENTRANT -DRELEASE -DSCRAMBLE_SYMBOLS $(MYUTILS_INCFLAGS)
MYUTILS_SCRAMBLED_LDFLAG:=
MYUTILS_SCRAMBLED_LIBS:=

endif

ifeq ($(SYSTEM), Linux)
MYUTILS_DEBUG_CFLAGS:=-g -Wall -W -Woverloaded-virtual -D_REENTRANT -DDEBUG $(MYUTILS_INCFLAGS)
MYUTILS_DEBUG_LDFLAG:=
MYUTILS_DEBUG_LIBS:=

MYUTILS_RELEASE_CFLAGS:=-Wall -W -Woverloaded-virtual -D_REENTRANT -DRELEASE $(MYUTILS_INCFLAGS)
MYUTILS_RELEASE_LDFLAG:=
MYUTILS_RELEASE_LIBS:=

MYUTILS_SCRAMBLED_CFLAGS:=-Wall -W -Woverloaded-virtual -D_REENTRANT -DRELEASE -DSCRAMBLE_SYMBOLS $(MYUTILS_INCFLAGS)
MYUTILS_SCRAMBLED_LDFLAG:=
MYUTILS_SCRAMBLED_LIBS:=

endif

MYUTILS_SRC:=$(shell ls 2>&1 $(MYUTILS_BASEDIR)/src/*.cpp) $(shell ls 2>&1 $(MYUTILS_BASEDIR)/src/*.c)

TMP_MYUTILS_OBJ:= $(patsubst %.cpp,%.o,$(filter %.cpp,$(MYUTILS_SRC))) $(patsubst %.c,%.o,$(filter %.c,$(MYUTILS_SRC)))
TMP_MYUTILS_DEP:= $(patsubst %.cpp,%.d,$(filter %.cpp,$(MYUTILS_SRC))) $(patsubst %.c,%.d,$(filter %.c,$(MYUTILS_SRC)))

SRC+=$(MYUTILS_SRC)

MYUTILS_DEBUG_OBJS=$(shell echo $(TMP_MYUTILS_OBJ) | sed -e 's@src@obj/debug@g' )
MYUTILS_RELEASE_OBJS+=$(shell echo $(TMP_MYUTILS_OBJ) | sed -e 's@src@obj/release@g' )
MYUTILS_SCRAMBLED_OBJS+=$(shell echo $(TMP_MYUTILS_OBJ) | sed -e 's@src@obj/scrambled@g' )

DEBUG_OBJS+=$(MYUTILS_DEBUG_OBJS)
RELEASE_OBJS+=$(MYUTILS_RELEASE_OBJS)
SCRAMBLED_OBJS+=$(MYUTILS_SCRAMBLED_OBJS)

# Dependencies are release independant.
DEPS+=$(shell echo $(TMP_MYUTILS_DEP) | sed -e 's@src@dep@g' )

DEBUG_MYUTILS_ARCHIVE:=$(BASEDIR)/lib/debug/$(MYUTILS).a
RELEASE_MYUTILS_ARCHIVE:=$(BASEDIR)/lib/release/$(MYUTILS).a
SCRAMBLED_MYUTILS_ARCHIVE:=$(BASEDIR)/lib/scrambled/$(MYUTILS).a

DEBUG_ARCHIVES+=$(DEBUG_MYUTILS_ARCHIVE)
RELEASE_ARCHIVES+=$(RELEASE_MYUTILS_ARCHIVE)
SCRAMBLED_ARCHIVES+=$(SCRAMBLED_MYUTILS_ARCHIVE)
